﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Perovich.GameObjects.Attributes;
using System.Reflection;
using Perovich.GameObjects.Tools.Util;
using System.CodeDom;

namespace Perovich.GameObjects.Components
{
    [AutomaticProperty("X", "Position2D.X", XmlSummary = "Gets or sets the X position of the entity.", XmlReturns = "A <see cref=\"System.Single\">float</see> that is the entity's X position.")]
    [AutomaticProperty("Y", "Position2D.Y", XmlSummary = "Gets or sets the Y position of the entity.", XmlReturns = "A <see cref=\"System.Single\">float</see> that is the entity's Y position.")]
    [AutomaticProperty("Position", "Position2D.Position", XmlSummary = "Gets or sets the position of the entity.", XmlReturns = "A <see cref=\"vector2\">Vector2</see> that is the entity's position.")]
    [AutomaticImport("Microsoft.Xna.Framework", false)]
    [AutomaticImport("Microsoft.Xna.Framework", true)]
    public sealed class Position2D : EntityComponent
    {

        Vector2 position;
        public Position2D()
        {
            position = Vector2.Zero;
        }

        public float X
        {
            get
            {
                return position.X;
            }
            set
            {
                position = new Vector2(value, position.Y);
            }
        }

        public float Y
        {
            get
            {
                return position.Y;
            }
            set
            {
                position = new Vector2(position.X, value);
            }
        }

        public Vector2 Position
        {
            get
            {
                return position;
            }
            set
            {
                position = value;
            }
        }

        public override void Initialize()
        {
            UpdateOrder = Constants.PositionUpdateOrder;
            base.Initialize();
        }

    }
}
